package cn.dylan.controller;

import cn.dylan.domain.Store;
import cn.dylan.service.IStoreService;
import cn.dylan.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/store")
public class StoreController {

    @Autowired
    private IStoreService storeService;

    @PostMapping("/save")
    public JsonResult handlerAdd(@RequestBody Store store){
        try {
            storeService.save(store);
            return JsonResult.me();
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.me().setMsg("网络故障，稍后重试");
        }
    }
}
